import com.powerfl.frm.taf.*;

public var tweenDelay:Object = {};
final public function addDelay( ...$param ):void{
	orderAdd( null, TAFtween.setRenderFixed, SELF.tweenDelay, '', '', $paramGet( $param ) );
}
final public function delayRemove( $setComplete:Boolean = false ):void{
	TAFtween.REMOVE( SELF.tweenDelay, $setComplete );
}
private function tweenParamCheck( $param:Array ):void{
	if( $param.indexOf( '@@TAFtweenVar' ) === -1 && $param.indexOf( TAFtweenVar ) === -1 ){
		paramTweenVarSet();
		$param[$param.length] = '@@TAFtweenVar';
	}	
}
final public function tweenRenderActivate( $tree:*, $timeline:String, ...$param ):void{
	tweenParamCheck( $param );
	orderAdd( null, tweenAdd_, TAFtween.setRenderActivate, $tree, $timeline, $paramGet( $param ) );
}
final public function tweenRenderDeactivate( $tree:*, $timeline:String, ...$param ):void{
	tweenParamCheck( $param );
	orderAdd( null, tweenAdd_, TAFtween.setRenderDectivate, $tree, $timeline, $paramGet( $param ) );
}
final public function tweenRenderFixed( $tree:*, $timeline:String, ...$param ):void{
	tweenParamCheck( $param );
	orderAdd( null, tweenAdd_, TAFtween.setRenderFixed, $tree, $timeline, $paramGet( $param ) );
}
final public function tweenLogicActivate( $tree:*, $timeline:String, ...$param ):void{
	tweenParamCheck( $param );
	orderAdd( null, tweenAdd_, TAFtween.setLogicActivate, $tree, $timeline, $paramGet( $param ) );
}
final public function tweenLogicDeactivate( $tree:*, $timeline:String, ...$param ):void{
	tweenParamCheck( $param );
	orderAdd( null, tweenAdd_, TAFtween.setLogicDectivate, $tree, $timeline, $paramGet( $param ) );
}
final public function tweenLogicFixed( $tree:*, $timeline:String, ...$param ):void{
	tweenParamCheck( $param );
	orderAdd( null, tweenAdd_, TAFtween.setLogicFixed, $tree, $timeline, $paramGet( $param ) );
}
private function tweenAdd_( $tween:Function, $tree:*, $timeline:String, $param:TAFparam ):void{
	var key:*, key2:*, i:int, j:int;
	if( $tree is Array ){
		$tree = arrayStrip( $tree );
		for each( key in $tree ){
			if( key is String ){
				if( key.charAt(0) === '@' ){
					for each( key2 in tagGet( key.substr( 1 ) ) ){
						$tween( tdata( key2 ), key2, $timeline, $param );
					}
				}else{
					$tween( tdata( key ), key, $timeline, $param );
				}
				
			}else{
				$tween( key, '', $timeline, $param );
			}
		}
	}else if( $tree is String ){
		if( $tree.charAt(0) === '@' ){
			for each( key in tagGet( $tree.substr( 1 ) ) ){
				$tween( tdata( key ), key, $timeline, $param );
			}
		}else{
			$tween( tdata( $tree ), $tree, $timeline, $param );
		}
	}else{
		$tween( $tree, '', $timeline, $param );
	}
}

final public function tweenRemove( $key:String = '', $setComplete:Boolean = false ):void{
	orderAdd( null, tweenRemove_, $key, $setComplete );
}
private function tweenRemove_( $key:String, $setComplete:Boolean ):void{
	if( $key ){
		TAFtween.REMOVE( tdata( $key ), $setComplete );
	}else{
		TAFtween.REMOVEALL( $setComplete );
	}
}
final public function tweenPause( $key:String = '' ):void{
	orderAdd( null, TAFtween.PAUSE, tdata( $key ) );
}
final public function tweenResume( $key:String = '' ):void{
	orderAdd( null, TAFtween.RESUME, tdata( $key ) );
}
final public function tweenLine( $key:String, ...$times ):void{
	TAFtween.TIMELINE( $key, $times, null );
}
final public function tweenLineData( $key:String, $data:Array, $mask:Array = null ):void{
	TAFtween.TIMELINE( $key, $data, $mask );
}